/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ericsson.nfc.signing;

import com.ericsson.nfc.signing.algorithm.PublicKey;
import com.ericsson.nfc.signing.algorithm.SignatureException;
import com.ericsson.nfc.signing.algorithm.SignatureVerifier;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.digests.MD5Digest;

/**
 *
 * @author emarkki
 */
public class OtherAlgVerifier implements SignatureVerifier {

    public boolean verifySignature(byte[] signature, byte[] coveredBytes, PublicKey publicKey) throws SignatureException {
        Digest digest = new MD5Digest();
        byte[] out = new byte[digest.getDigestSize()];
        digest.update(coveredBytes, 0, coveredBytes.length);
        digest.doFinal(out, 0);
        return Utils.equals(signature, out);
    }

}
